package com.cswangdao.service.impl;

import com.cswangdao.domain.dto.CollectPageDTO;
import com.cswangdao.domain.model.MarketAddress;
import com.cswangdao.domain.model.MarketCollect;
import com.cswangdao.mapper.MarketCollectMapper;
import com.cswangdao.result.PageResult;
import com.cswangdao.service.CollectService;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class CollectServiceImpl implements CollectService {
    @Autowired
    private MarketCollectMapper collectMapper;

    @Override
    public PageResult<MarketCollect> pageQueryInfo(CollectPageDTO collectPageDTO) {
        try/*(SqlSession sqlSession = MybatisUtil.getSqlSession(true))*/ {
        //    MarketCollectMapper collectMapper = sqlSession.getMapper(MarketCollectMapper.class);
            PageHelper.startPage(collectPageDTO.getPage(),collectPageDTO.getLimit());
            Page<MarketCollect> collectPage = collectMapper.pageQueryInfo(collectPageDTO);
            PageResult<MarketCollect> result = PageResult.result(collectPage);
            return result;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}
